﻿@addTagHelper *, WebVella.Erp.Plugins.Core
@addTagHelper *, WebVella.Erp.Web
@addTagHelper *, WebVella.TagHelpers

@using WebVella.Erp.Web.Components;
@using WebVella.Erp.Web.Models;
@using WebVella.Erp.Web.Utils;
@{
	var options = (PcBtnGroup.PcBtnGroupOptions)ViewBag.Options;
	var node = (PageBodyNode)ViewBag.Node;
	var componentContext = (PageComponentContext)ViewBag.ComponentContext;
}
<wv-button-group size="@options.Size" is-vertical="@options.IsVertical" class="@options.Class" id="@options.Id" is-visible="(bool)ViewBag.IsVisible">
@foreach (var childNode in node.Nodes)
{
	var nodeComponentName = "";
	if (childNode != null)
	{
		var nameArray = childNode.ComponentName.Split('.');
		nodeComponentName = nameArray[nameArray.Length - 1];
	}
	if (!String.IsNullOrWhiteSpace(nodeComponentName))
	{
		var childOptions = PageUtils.ConvertStringToJObject(childNode.Options.ToString());
		var pcContext = new PageComponentContext(childNode, componentContext.DataModel, ComponentMode.Display, childOptions, componentContext.Items);
		@await Component.InvokeAsync(nodeComponentName, new { context = pcContext })
	}
}
</wv-button-group>
